package cn.hl.hm.controller;


import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.hl.hm.entity.TFeedbackEntity;
import cn.hl.hm.service.TFeedbackService;
import cn.hl.hm.util.InfoCode;
import cn.hl.hm.util.Result;
import cn.hl.hm.util.Tools;


@Controller
@RequestMapping("/backstageTFeedbackController")
public class BackstageTFeedbackController {
	private static Logger logger = Logger.getLogger(BackstageTFeedbackController.class);
	@Autowired
	private TFeedbackService tFeedbackService; 

	//查看意见反馈列表
	@RequestMapping(value = "/backstageFeedbackList", method = RequestMethod.POST)
	 public
	    @ResponseBody
	    String backstageFeedbackList(
	    		@RequestParam(value = "phone", required = false) String phone,
	    		@RequestParam(value = "createTime", required = false) String createTime,
	    		@RequestParam(value = "limit", required = false) Integer limit,
	    		@RequestParam(value = "pageSize", required = false) Integer pageSize,
	    		HttpServletRequest request, HttpServletResponse response) {
		try{
			 List<TFeedbackEntity> tfeList=tFeedbackService.backstageFeedbackList(phone, createTime, limit, pageSize);
			 Result.ok(tfeList, InfoCode.SUCCESS, response); 
			// ResposeUtils.resultAdmin(tfeList, "1", response);
			 return null;
		}catch(Exception e){
			e.printStackTrace();
			logger.error(e);
			 Result.ok(null, InfoCode.FAILURE, response); 
		}
		    		  
						return null;
	
		}
	//查询单条反馈信息
	@RequestMapping(value = "/selectfeedbackOne", method = RequestMethod.POST)
	 public
	    @ResponseBody
	    String selectfeedbackOne(
	    		@RequestParam(value = "id", required = true) Integer id,
	    		HttpServletRequest request, HttpServletResponse response) {
		try{
			if(Tools.isInteger(id)){
				 Result.ok(null, InfoCode.FAILURE, response); 
				 return null;
			}
			 TFeedbackEntity tfe=tFeedbackService.selectfeedbackOne(id);
			 Result.ok(tfe, InfoCode.SUCCESS, response); 
			 return null;
		}catch(Exception e){
			e.printStackTrace();
			logger.error(e);
			 Result.ok(null, InfoCode.FAILURE, response); 
		}
		    		 
						return null;
	
		}
}
